@extends('admin.public.header')
@section('title','调整会员账户资金')

@section('listcontent')
    <div class="layui-tab-content">
        <form class="layui-form">
            <div class="layui-form layuimini-form">
                <input type="hidden" name="id" value="{{ $param['id'] ?? '' }}">
                <input type="hidden" name="type" value="{{ $param['type'] ?? '' }}">

                @if($param['type'] == 1)
                <div class="layui-form-item">
                    <label class="layui-form-label required">可用余额</label>
                    <div class="layui-input-block">
                        <input type="number" name="money" value="{{$info->money ?? 0 }}" class="layui-input" disabled>
                        <tip></tip>
                    </div>
                </div>
                @elseif($param['type'] == 2)
                <div class="layui-form-item">
                    <label class="layui-form-label required">可用积分</label>
                    <div class="layui-input-block">
                        <input type="number" name="integral" value="{{$info->integral ?? 0 }}" class="layui-input" disabled>
                        <tip>修改玩家积分为直接操作数据，请谨慎修改</tip>
                    </div>
                </div>
                @endif

                <div class="layui-form-item">
                    <label class="layui-form-label required">类型</label>
                    <div class="layui-input-block">
                        <input type="radio" name="operate" value="1" title="充值" checked>
                        <input type="radio" name="operate" value="2" title="扣除">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label required">金额</label>
                    <div class="layui-input-block">
                        <input type="number" name="amount" lay-verify="required" lay-reqtext="金额不能为空" placeholder="请输入金额" value="0" class="layui-input">
                        <tip>修改玩家余额为直接操作数据，请谨慎修改</tip>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <textarea name="description" placeholder="请输入备注" class="layui-textarea"></textarea>
                    </div>
                </div>
            </div>
            <div class="hr-line"></div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" id="saveBtn" lay-submit lay-filter="saveBtn">确认保存</button>
                </div>
            </div>
        </form>
    </div>

@endsection

@section('listscript')
    <script type="text/javascript">
        layui.use(['layer','form','laydate'], function () {
            var layer = layui.layer, form = layui.form, $=layui.jquery ,laydate = layui.laydate;
            
            form.on('submit(saveBtn)', function(data){
                var loading = layer.msg('加载中..', {icon: 16,shade: 0.3,time: false});
                $.ajax({
                    url:'/admin/user/edit-capital',
                    type:'post',
                    data: data.field,
                    dataType:"JSON",
                    headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
                    success:function(res){
                        layer.close(loading);  //返回数据关闭loading
                        if(res.code == 0){
                            layer.msg(res.msg, {icon: 1},function(){
                                setTimeout('parent.location.reload()',500);
                            });
                        }
                        else{
                            layer.msg(res.msg,{icon: 2});
                        }
                    },
                    error:function(e){
                        layer.close(loading);
                        layer.msg("提交失败",{icon: 2});
                    },
                });
                return false;
            });
        });
    </script>
@endsection

